# -*- encoding: utf-8 -*-
# @File    :   article.py
# @Time    :   2021/07/27 12:18:07
# @Author  :   wudongmin
# @Contact :   wudongmin@xroom.net
# @version   :  1.0

from fastapi import APIRouter, Depends
from app.service.article import ServiceArticle
from app.items import pagnation_common_params, order_common_params
from fastapi import Request
from app.routes import response_code

router_article = APIRouter()
service = ServiceArticle()

@router_article.get("/article/types")
def article_type_list(request: Request):
    # 文章类型列表
    res = service.get_article_type_list()
    return response_code.resp_200(data=res)

@router_article.get("/articles")
def article_list(request: Request,
                 page_params: dict = Depends(pagnation_common_params),
                 order_params: dict = Depends(order_common_params)):
    # 文章列表 
    res = service.get_article_list(page_params=page_params, order_params=order_params)
    return response_code.resp_200(data=res)     

@router_article.get("/article/{id}")
def article_detail(request: Request, id: int):
    # 文章详情
    res = service.get_article_detail(id)
    return response_code.resp_200(data=res)

@router_article.get("/animations")
def animation_list(request: Request):
    # 获取我追的番剧列表
    res = service.get_animation_list()
    return response_code.resp_200(data=res)
